<?php

Route::get('/', function () {
    return view('welcome');
});


Route::group(['prefix' => 'wechat'], function () {
    Route::get('/login', 'WxxcxController@login');

    Route::group(['middleware' => 'wechat.session'], function () {
        Route::get('/getWxUserInfo', 'WxxcxController@getWxUserInfo');
    });
});


Route::group(['namespace' => 'Admin'], function () {

    Route::group(['prefix' => 'admin'], function () {

        Route::get('/login', 'LoginController@index');//登录展示页面
        Route::post('/login', 'LoginController@login');//登录行为
        Route::get('/logout', 'LoginController@logout');//登出行为

        //#检查登录
        Route::group(['middleware' => 'auth:admin'], function () {
            Route::get('/home', 'HomeController@index');

            Route::group(['middleware' => 'can:system'], function () {
                #管理
                Route::get('/users', 'UserController@index');
                Route::get('/users/create', 'UserController@create');
                Route::post('/users/store', 'UserController@store');
                Route::get('/users/{user}/role', 'UserController@role');
                Route::post('/users/{user}/role', 'UserController@storeRole');

                #rbac（角色）
                Route::get('/roles', 'RoleController@index');
                Route::get('/roles/create', 'RoleController@create');
                Route::post('/roles/store', 'RoleController@store');
                Route::get('/roles/{role}/permission', 'RoleController@permission');
                Route::post('/roles/{role}/permission', 'RoleController@storePermission');

                #rbac (权限)
                Route::get('/permissions', 'PermissionController@index');
                Route::get('/permissions/create', 'PermissionController@create');
                Route::post('/permissions/store', 'PermissionController@store');
            });
            #新增功能模块
            Route::group(['middleware' => 'can:examine'], function () {

            });
        });
    });
});
